<?php
require_once("class.markup_config.php");
require_once("class.db_handler.php");
require_once("class.request_fetcher.php");
//header("Content-type: aplication/json");
$req_fet= new request_fetcher();
$req_fet->search_by_codes($_REQUEST["dep"][0],$_REQUEST["dep_type"],$_REQUEST["ret"][0],$_REQUEST["ret_type"]);


$config_id=$req_fet->config_id;

echo $config_id;



$fare_type=$_REQUEST["fare_type"];
$airline_code=$_REQUEST["ailie"][0];
$trip_type=$_REQUEST["trip_type"];
$ptc=$_REQUEST["ptc"];
$cabin_class=$_REQUEST["cabin_class"];
$sid=$_REQUEST["sid"];
$range=$_REQUEST["range"];
$time_search=$_REQUEST["time_search"];
$flight_type=$_REQUEST["flight_type"] ;
$mark= new  markup_config($config_id,$fare_type,$airline_code,$trip_type,$ptc,$cabin_class,$sid,$range,$time_search,$flight_type);
$mark->assign_markup();
$i=0;
$page=1;
$total=count($arr);
$rows=array();

/*foreach($mark->config_mark as $row)
{  
$elo=markup_configs_helper::get_markup_rule_by_rule_id($row["rule_id"]); 
 $row1=array();
 $row1["cell"]=array($row["start_date"],$row["end_date"],$row["fare_type"],$row["airline_code"],$row["trip_type"],$row["ptc"],$row["cabin_class"],$row["sid"],$row["price_range"],$row["time_search"],$row["flight_type"],$row["priority"],$elo[0]["markup_type"],$elo[0]["markup_value_type"],$elo[0]["markup_apply_on"],$elo[0]["value"]);
 $row1["id"]=$i;
 $i++;
 $rows[]=$row1;
}
echo json_encode(array("page"=>$page,"rows"=>$rows,"total"=>$total,"conf"=>$config_id));    */

echo "<br><br>	<table width=\"800\" border=\"1\" cellpadding='4' cellspacing='1'>";
echo "<tr><th width=\"50\">Start Date</th><th width=\"50\">End Date</th><th width=\"50\">Fare Type</th><th width=\"50\">Air Line</th><th width=\"50\">Trip Type</th><th width=\"50\">PTC</th><th width=\"50\">Class</th><th width=\"50\">SID</th><th width=\"50\">Price Range</th><th width=\"50\">Search Time</th><th width=\"50\">Flight Type</th><th width=\"50\">Priority</th><th width=\"50\">Markup Type</th><th width=\"50\">Mark Value Type</th><th width=\"50\">Markup Apply On</th><th width=\"50\">Value</th></tr>";
$i=0;
foreach($mark->config_mark as $ele){
  $elo=markup_configs_helper::get_markup_rule_by_rule_id($ele["rule_id"]);   
   if($i==0){
	   $color ="#E0FEDE";
   }
   else{
	   $color="#E5E5E5";
	   }
    echo "<tr>";
    echo "<td bgcolor='$color'>".$ele["start_date"]."</td>";
    echo "<td bgcolor='$color'>".$ele["end_date"]."</td>";
    echo "<td bgcolor='$color'>".$ele["fare_type"]."</td>";
    echo "<td bgcolor='$color'>".$ele["airline_code"]."</td>";
    echo "<td bgcolor='$color'>".$ele["trip_type"]."</td>";
    echo "<td bgcolor='$color'>".$ele["ptc"]."</td>";
    echo "<td bgcolor='$color'>".$ele["cabin_class"]."</td>";
    echo "<td bgcolor='$color'>".$ele["sid"]."</td>";
    echo "<td bgcolor='$color'>".$ele["price_range"]."</td>";
    echo "<td bgcolor='$color'>".$ele["time_search"]."</td>";
    echo "<td bgcolor='$color'>".$ele["flight_type"]."</td>";
    echo "<td bgcolor='$color'>".$ele["priority"]."</td>";   
    echo "<td bgcolor='$color'>".$elo["markup_type"]."</td>";
    echo "<td bgcolor='$color'>".$elo["markup_value_type"]."</td>";
    echo "<td bgcolor='$color'>".$elo["markup_apply_on"]."</td>";
    echo "<td bgcolor='$color'>".$elo["value"]."</td>";
    
    echo "</tr>";
	$i++;
    }
echo "</tr></table>";                       
?>
